package spark;

import groovy.lang.GroovyClassLoader;
import groovy.lang.GroovyObject;

import java.io.File;
import java.io.IOException;

/**
 * 作者: LDL
 * 功能说明:
 * 创建日期: 2015/6/26 14:18
 */
public class GroovyCall {
    public static void main(String[] args) throws IOException, IllegalAccessException, InstantiationException {
        /*GroovyShell shell = new GroovyShell();
        shell.run(new File("D:\\GroovyTest.groovy"), Lists.newArrayList());*/

        ClassLoader parent = GroovyCall.class.getClassLoader();
        GroovyClassLoader loader = new GroovyClassLoader(parent);

        Class groovyClass = loader.parseClass(
                new File("D:\\GroovyTest.groovy"));

        GroovyObject groovyObject = (GroovyObject) groovyClass.newInstance();

        Object[] argz = {};

        System.out.println(groovyObject.invokeMethod("getString", argz));
        System.out.println("finish");
    }
}
